package com.hpu.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.hpu.entity.Menu_Comment;
import com.hpu.util.DBhelp;
import com.hpu.util.RowMapper;

public class MenuCommentDao {
	private DBhelp<Menu_Comment> dbhelp = new DBhelp<Menu_Comment>();
	
	public List<Menu_Comment> findAllComments(){
		String sql = "select id,comment,createtime,menu_id,order_id from menu_comment order by createtime desc";
		return dbhelp.executeQueryForList(sql, new MenuCommentRowMapper());
	}

	private class MenuCommentRowMapper implements RowMapper<Menu_Comment>{
		public Menu_Comment mapperRow(ResultSet rs) throws SQLException {
			Menu_Comment menuComment = new Menu_Comment();
			menuComment.setId(rs.getInt("id"));
			menuComment.setComment(rs.getString("comment"));
			menuComment.setCreatetime(rs.getString("createtime"));
			menuComment.setMenu_id(rs.getInt("menu_id"));
			menuComment.setOrder_id(rs.getInt("order_id"));
			return menuComment;
		}
		
		
	}
}
